package com.yswy.backstage.dto.res;

import com.yswy.domain.entity.user.Permission;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author 19401
 * @date 2022/6/6 10:29
 **/
@Data
public class MenuTreeResVO {
    private Long id;
    @ApiModelProperty("路由地址")
    private String path;
    @ApiModelProperty("组件地址")
    private String component;
    @ApiModelProperty("重定向地址，当设置 noRedirect 的时候该路由在面包屑导航中不可被点击")
    private String redirect;
    @ApiModelProperty("当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面")
    private Boolean alwaysShow;
    @ApiModelProperty("其他元素")
    private MenuTreeMetaResVo meta;

    @ApiModelProperty("是否隐藏路由，当设置 true 的时候该路由不会再侧边栏出现")
    private boolean hidden;

    @ApiModelProperty("父级")
    private Long pId;
    @ApiModelProperty("排序")
    private Integer orderBy;

    @ApiModelProperty("子路由")
    private List<MenuTreeResVO> children;

    public MenuTreeResVO(Permission bo) {
        this.id = bo.getId();
        this.path = bo.getPath();
        this.hidden = bo.getIsHidden() == 1;
        this.redirect = bo.getRedirect();
        this.component = bo.getComponent();
        this.meta = new MenuTreeMetaResVo(bo.getPermissionName(), bo.getIcon(), bo.getIsCache() == 1, bo.getLink());
        this.pId = bo.getPId();
        this.orderBy = bo.getOrderBy();
    }
}
